package com.lovo.service.impl;

import com.lovo.bean.Suppliermsg;
import com.lovo.bean.Tenderinfo;
import com.lovo.dto.SupplierMsgDto;
import com.lovo.dto.TenderInfoDto;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MQSService {

    @Autowired
    RabbitTemplate rabbitTemplate;

    public void sendMsg(SupplierMsgDto supplierMsgDto) {
        rabbitTemplate.setMandatory(true);
        CorrelationData correlationData = new CorrelationData("ok");
        rabbitTemplate.convertAndSend("directExchangeMsg", "msg.key", supplierMsgDto, correlationData);
    }

    public void sendTenderInfo(TenderInfoDto tenderInfoDto) {
        rabbitTemplate.setMandatory(true);
        CorrelationData correlationData = new CorrelationData("ok");
        rabbitTemplate.convertAndSend("directExchangeInfo", "info.key", tenderInfoDto, correlationData);
    }

}
